################
#PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
#
#Observational Data: Eurobarometer
#Part III: Benefits
#
#Verena Fetscher
#July 2022
####################

rm(list=ls())

####################
# Load data
####################
# EB
load("EB_gini_17.Rda")

# Benefit Concentration
load("Benefits.Rda")

df %>%
  group_by(cntry) %>%
  filter(time=="Mean") %>%
  summarise(rr=mean(allRepl)) -> benefits


# Merge data
df_merge <- merge(EB, benefits, by.x = c("cntry_short"), 
                  by.y = c("cntry"), all.x = TRUE, all.y = FALSE)


df_merge %>%
  group_by(cntry) %>%
  summarise(rr=mean(rr, na.rm=T))


####################
# Save data
####################
save(df_merge, file = "EB_benefits_17.Rda")
